using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Risiko.State
{

  public struct Board
  {
    // LOGIC DATA
    public Continent[] continents;

    // RENDER DATA
    public List<Animation> ActiveAnimations;

    public Continent GetContinent(int id)
    {
      return continents[id];
    }

    public Territory GetTerritory(TerritoryReference tRef)
    {
      return continents[tRef.continentID].territories[tRef.territoryID];
    }

    public TerritoryReference[] GetNeighbors(TerritoryReference tRef)
    {
      return GetTerritory(tRef).neighbors;
    }

    public void IterTerritories(Func<Territory, Territory> f)
    {
      for (int i = 0; i < continents.Length; i++)
      {
        for (int j = 0; j < continents[i].territories.Length; j++)
        {
          continents[i].territories[j] = f(continents[i].territories[j]);
        }
      }
    }

    public void IterTerritories(Action<Territory> f)
    {
      for (int i = 0; i < continents.Length; i++)
      {
        for (int j = 0; j < continents[i].territories.Length; j++)
        {
          f(continents[i].territories[j]);
        }
      }
    }

  }

}
